﻿using System;
using System.Windows.Forms;
using System.IO;

namespace TaleGeneratorInterface
{
    public partial class NewNetForm : Form
    {
        public string KBName { get { return tbxName.Text; } }
        public string KBPath { get { return tbxDirectory.Text; } }

        public NewNetForm()
        {
            InitializeComponent();
            tbxDirectory.Text = @"C:\Temp\";
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
                tbxDirectory.Text = folderBrowserDialog1.SelectedPath;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (Directory.Exists(tbxDirectory.Text))
                if (!string.IsNullOrEmpty(tbxName.Text))
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                else
                    MessageBox.Show("Введите имя базы знаний", "Ошибка");
            else
                MessageBox.Show("Указанная директория не существует", "Ошибка");
        }

        private void tbxName_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
                button1_Click(null, null);
        }
    }
}
